
import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCanvas;
import org.doublepane.SimpleJOGL;



/**
 *
 * Compiler: jdk1.6.0_14 <br />
 * IDE: NetBeans 6.7.1 <br />
 * @author Andrew Smith <br />
 */
public class Run
{
    //size of the frames
    private static final int WIDTH = 640;
    private static final int HEIGHT = 480;

    public static void main(String[] args) {

        int currentPos = -WIDTH/2;
        

        for(int i=0; i<2; i++)
        {

            Frame frame = new Frame("Simple JOGL Application"); //main frame
            GLCanvas canvas1 = new GLCanvas();
            //GLCanvas canvas2 = new GLCanvas();

            canvas1.addGLEventListener(new SimpleJOGL());
            //canvas2.addGLEventListener(new SimpleJOGL());

            frame.add(canvas1);
            //frame.add(canvas2);

            frame.setSize(WIDTH, HEIGHT);

            final Animator animator1 = new Animator(canvas1);
            //final Animator animator2 = new Animator(canvas2);

            frame.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent e) {
                    // Run this on another thread than the AWT event queue to
                    // make sure the call to Animator.stop() completes before
                    // exiting
                    new Thread(new Runnable() {

                        public void run() {
                            animator1.stop();
                            //animator2.stop();
                            System.exit(0);
                        }
                    }).start();
                }
            });
            // Center frame
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);

            frame.setLocation(frame.getLocationOnScreen().x-currentPos, frame.getLocationOnScreen().y);
            animator1.start();

            currentPos = +WIDTH/2;
            //animator2.start();
        }
    }
}
